package com.bt7274.enums;

import lombok.Getter;

/**
 * 用户权限组枚举
 * 对应不同的用户等级和权限
 */
@Getter
public enum PermissionGroupEnum {

    INTERN(0, "见习生", "免费注册用户默认等级"),
    GRADUATE(1, "毕业生", "使用邀请码注册的用户默认等级"),
    JUNIOR_DRIVER(2, "初级铁驭", "初级用户"),
    QUALIFIED_DRIVER(3, "合格铁驭", "合格用户"),
    FAMOUS_DRIVER(4, "知名铁驭", "知名用户"),
    GLORY_DRIVER(5, "荣耀铁驭", "荣耀用户"),
    LEGENDARY_DRIVER(6, "传奇铁驭", "传奇用户"),
    BT_SUPREME(7, "BT至尊", "最高等级用户");

    private final Integer code;
    private final String name;
    private final String description;

    PermissionGroupEnum(Integer code, String name, String description) {
        this.code = code;
        this.name = name;
        this.description = description;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据代码获取权限组
     *
     * @param code 权限组代码
     * @return 权限组枚举
     */
    public static PermissionGroupEnum getByCode(Integer code) {
        for (PermissionGroupEnum group : values()) {
            if (group.getCode().equals(code)) {
                return group;
            }
        }
        return INTERN; // 默认返回见习生
    }
}